package com.cloud.code.真题;

public class Demo21 {

    public static void main(String[] args) {
        int n = 4;

        String str = "1";
        for (int i = 0; i < n; i++) {

            StringBuilder strs = new StringBuilder();
            char[] chars = str.toCharArray();
            char cur = chars[0];
            int count = 0;
            for (int j = 0; j < chars.length; j++) {
                if(chars[j] == cur){
                    count++;

                }else {
                    strs.append(count).append(cur);
                    cur = chars[j];
                    count=1;

                }
                if(j == chars.length-1){
                    strs.append(count).append(cur);
                    cur = chars[j];
                }
            }

            str = strs.toString();
        }

        System.out.println(str);

    }
}
